
$("#changepassword").click(function () {
    var newpwd1 = $("#new-password").val();
    var confirm = $("#confirm-password").val();
    alert(newpwd1);
    alert(confirm);

    if(newpwd1===confirm){
        changepassword();
    }
    if(newpwd1!==confirm){
        alert(111)
        window.location.href = "changePasswordInit";
    }

})




function changepassword() {
    var oldpwd = $("#old-password").val();
    var newpwd = $("#new-password").val();

    $.ajax({
        url: "changePassword",
        type: "post",
        data: {"oldpwd":oldpwd,"newpwd":newpwd},
        success: function (data) {
            if (data == "1") {
                alert("修改成功！")
                window.location.href = "indexInit";
            } else if (data == "0") {
                alert("修改失败！");

            }
        },
        error: function () {
            alert("失败")
        }
    })

}


